<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>边框动画</title>
    <style>
        .box{
            width:800px;
            border:1px solid tan;
            margin:0 auto 20px auto;
            padding: 20px 100px;
            box-sizing: border-box;
        }
        .box-item{
            height:100px;
        }
        .border-length{
            position:relative;
            border:1px skyblue solid;
        }
        .border-length::before,.border-length::after{
            content: "";
            position: absolute;
            width: 150px;
            height: 75px;
            transition: .3s ease-in-out;
        }
        .border-length::before{
            top:-10px;
            left:-10px;
            border-top:1px solid skyblue;
            border-left:1px solid skyblue;
        }
        .border-length::after{
            bottom:-10px;
            right:-10px;
            border-bottom:1px solid skyblue;
            border-right:1px solid skyblue;
        }
        .border-length:hover::before,
        .border-length:hover::after {
            width: calc(100% + 19px);
            height: calc(100% + 19px);
        }
    </style>
</head>
<body>
    <div class="box">
        <p>边框长度变化</p>
        <div class="box-item border-length"></div>
    </div>
</body>
</html>